package com.yueka.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yueka.pojo.entity.teacher.Teacher;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface TeacherMapper extends BaseMapper<Teacher> {

    Page<Teacher> list(@Param("page") Page<Teacher> page, @Param("keyword") String keyword, @Param("status") String status);

    @Update("update teacher set teacher.teacher_name = #{teacherName},gender = #{gender}, age = #{age}, phone = #{phone}, level = #{level}, email = #{email}, address = #{address}, status = #{status}, avatar = #{avatar}, description = #{description}, join_date = #{joinDate}, update_time = #{updateTime} where id = #{id}")
    void update(Teacher teacher);

    void delete(Integer[] ids);

    @Select("select id, teacher_name, gender, age, phone, level, email, address, status, avatar, join_date, description, update_time, create_time, (select GROUP_CONCAT(ic_name) from instrument_category where id in (select i_id from teacher_instrument where t_id = teacher.id)) as instrumentNames from teacher where status = '1'")
    List<Teacher> getTeacherList();
}
